package com.popay.es.controller;

import com.alibaba.fastjson.JSON;
import com.popay.common.utils.AjaxJson;
import com.popay.common.utils.exception.CustomException;
import com.popay.es.service.FeignServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

/**
 * @version v1.0
 * @ProjectName: xfs-springcloud-popay
 * @ClassName: TestController
 * @Description: TODO
 * @Author: 晨曦
 * @Date: 2021-6-2 15:21
 */
@Slf4j
@Api(value = "/测试", tags = {"测试"})
@RestController
@RefreshScope
@RequestMapping("/test")
public class TestController {
    @Value("${springfox.title}")
    private String title;
    @Value("${springfox.desc}")
    private String desc;

    @Autowired
    private FeignServer feignServer;

    /**
     * @Description: WMS推送采购小票
     * @Param: [purchaseInvoice]
     * @return: com.xfs.popay.common.utils.AjaxJson
     * @Author: CuiWei
     * @Date: 2019-2-22 17:26
     */
    @ApiOperation(value = "WMS推送采购小票", notes = "描述：WMS推送采购小票", httpMethod = "POST")
    @RequestMapping(value = "/insertPurchaseInvoice", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public AjaxJson insertPurchaseInvoice(@RequestBody Map map) throws CustomException {
        AjaxJson ajaxJson = new AjaxJson();
        log.info("WMS推送采购小票 入参 -> " + JSON.toJSONString(map));
        Map AjaxJsonMap = new HashMap();
        AjaxJsonMap.put("name", "晨曦");
        AjaxJsonMap.put("id", "0001");
        log.info("WMS推送采购小票 出参 -> " + JSON.toJSONString(map));
        return ajaxJson.setData(AjaxJsonMap);
    }

    @RequestMapping("/test")
    public String test() {
        return "title:" + title + " / " + "desc" + desc;
    }

    @GetMapping("/test1")
    public String test1() {
        return "参数";
    }

}
